package com.my.attendance.dao;

import com.my.attendance.entity.Position;
import com.my.attendance.util.BaseDAO;

import java.util.List;

public class PositionDao extends BaseDAO {

    public List<Position> getPositionList() throws Exception {
        String sql="select * from position;";
        List<Position> positionList = getList(sql, new Position(), new Object[0]);
        return positionList;
    }

    public Position getPosition(int position_number) throws Exception {
        String sql="select * from position where position_number=?;";
        Object[] obj={position_number};
        Position position = getOne(sql, new Position(), obj);
        return position;
    }

    public int updatePosition(int position_number,int employee_number) throws Exception {
        String sql="update position set position_number=? where employee_number=?;";
        Object[] obj={position_number,employee_number};
        int i = addOrupdOrdel(sql, obj);
        return i;
    }
}
